
//
//  WSSureOrderHeaderView.m
//  FD
//
//  Created by xiaofang wang on 2018/11/5.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "WSSureOrderHeaderView.h"
#import "WSSureOrderHdV.h"
#import "WSSureOrderDbV.h"
@interface WSSureOrderHeaderView()
/**1. hd 上面的 送餐方式*/
@property (nonatomic, strong) WSSureOrderHdV *hdView;

/**2.bd 下面的*/
@property (nonatomic, strong) WSSureOrderDbV *dbView;

@end

@implementation WSSureOrderHeaderView
#pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
    }
    return self;
}
- (void)setupView
{
    CGFloat sw = self.bounds.size.width;
    CGFloat sh = self.bounds.size.height;
    
    self.hdView = [[WSSureOrderHdV alloc] initWithFrame:CGRectMake(0, 0, sw, 50)];
    
    CGFloat dbview_y = self.hdView.rb_bottom;
    
    self.dbView = [[WSSureOrderDbV alloc] initWithFrame:CGRectMake(0, dbview_y, sw, sh-dbview_y)];

    [self addSubview:self.hdView];
    [self addSubview:self.dbView];
    
    //block回调 切换视图 添加回调方法
    __weak typeof(self) weakSelf  = self;
    // 送餐方式请求参数，NSNumber类型 0：外送 1：自提 2：门店预约
    self.hdView.clickTypeBlock = ^(WSSureOrderHdvType type) {
        if (type == WSSureOrderHdvTypeWS) {
//            [JRToast showWithText:@"外送"];
            [weakSelf.dbView hideZTView];
            
            weakSelf.wsSureOrderHeaderViewClickSongCanTypeBlock(@(0));
        }else {
            weakSelf.wsSureOrderHeaderViewClickSongCanTypeBlock(@(1));
//            [JRToast showWithText:@"自提"];
            [weakSelf.dbView hideWSView];
        }
    };
    
    //选择地址block 回调
    self.dbView.wsSureOrderDbVBlock = ^{
        if (weakSelf.wsSureOrderHeaderViewClickAddressBlock) {
            weakSelf.wsSureOrderHeaderViewClickAddressBlock();
        }
    };
}


#pragma mark - 接口
- (void)updateWSSureOrderHeaderViewReceiveAddress:(NSString *)address {
//    self.dbView.addressLb.text = address; //收货地址
    self.dbView.addressLb1.text = address;
    self.dbView.addressLb2.text = address;
}

@end
